package org.linuxgears.BouncingBall.painter;

import java.awt.Color;

import org.linuxgears.BouncingBall.model.Point;
import org.linuxgears.BouncingBall.model.Ball;
import org.linuxgears.BouncingBall.model.context.BallContext;

/**
 * Created by IntelliJ IDEA.
 * User: grim
 * Date: 9 ��� 2010
 * Time: 0:36:29
 * To change this template use File | Settings | File Templates.
 */
public class BallPainterFactory {
    private static BallPainterFactory instance = new BallPainterFactory();

    private BallPainterFactory() { };

    public SimpleBallPainter createBallPainter(Ball ball, BallContext context) {
        if (context != null) {
            return new SimpleBallPainter(ball.getColor(), ball.getSize(), context.getPosition());
        } else {
            return new SimpleBallPainter(ball.getColor(), ball.getSize(), new Point(0, 0));
        }
    }

    public SelectedBallPainter createSelectedBallPainter(Ball ball, BallContext context) {
        if (context != null) {
            return new SelectedBallPainter(ball.getColor(), ball.getSize(), context.getPosition());
        } else {
            return new SelectedBallPainter(ball.getColor(), ball.getSize(), new Point(0, 0));
        }
    }

    public static BallPainterFactory getInstance() {
        return instance;
    }
}
